#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fs.h>
#include <limits.h>

#define BLKGETSIZE64 _IOR(0x12,114,size_t)
int main(int argc, char** argv)
{

    printf("size of long = %d\n", sizeof(long));
    printf("max of long value = %d\n", LONG_MAX);
    int fd=open(argv[1], O_RDONLY|O_LARGEFILE);
    if (fd < 0)
    {
	    printf("failed to open %s\n", argv[1]);
	    exit(1);
    }	    

    unsigned long sizeInSectors; // (ie, 512 bytes)
    if(!ioctl(fd, BLKGETSIZE, &sizeInSectors))
    {
	    printf("size in ulong = %u\n", sizeInSectors);
    }

    long long ll=0;
    if(!ioctl(fd, BLKGETSIZE, &ll))
    {
	    printf("size in long long = %u\n", ll);
    }

    int blksize=0;
    if(!ioctl(fd, BLKBSZGET, &blksize))
    {
	    printf("block size = %d\n", blksize);
    }
    return 0;
}

